package wt.hpad.activity.cart;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;
import wt.hpad.ConstantFields;
import wt.hpad.R;
import wt.hpad.activity.order.OrderActivity;
import wt.hpad.utils.ActivityUtil;
import wt.hpad.utils.AppUtil;

/**
 * 购物车 activity
 */
public class CartActivity extends AppCompatActivity {

    @BindView(R.id.tv_goback_cart)
    TextView tvGobackCart;
    private CartFragment mCartFragment;
    private CartContract.Presenter mCartPresenter;
    /*    @BindView(R.id.cart_content)
    FrameLayout cartContent;*/

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.cart_act);

        initUI();
        initData();
    }

    private void initData() {
        tvGobackCart.setText(ConstantFields.CURRENT_TABLE + "桌:" + "返回继续点菜");
        tvGobackCart.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                backToOrder();
            }
        });
    }

    private void initUI() {
        ButterKnife.bind(this);
        AppUtil.hideBarAndTransparentTime(this);
        AppUtil.hideBottomUIMenuAll(this);
        mCartFragment = new CartFragment();
        ActivityUtil.addFragmentToActivity(getSupportFragmentManager(), mCartFragment, R.id.cart_content);
        mCartPresenter = new CartPresenter(mCartFragment);
        mCartFragment.setPresenter(mCartPresenter);
    }

    private void backToOrder() {
        startActivity(new Intent(getApplicationContext(), OrderActivity.class));
        this.finish();
    }


}
